#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<cmath>
#define x first
#define y second
using namespace std;
using pii = pair<int, int>;
const int N = 110, M = 170;
const double eps = 1e-8;
pii q[M];
int top, cnt;
char g[N][N];
double hashs[30];
int n, m;
void dfs(int a, int b)
{
    q[top++] = { a,b };
    g[a][b] = '0';
    for (int i = a - 1; i <= a + 1; i++)
    {
        for (int j = b - 1; j <= b + 1; j++)
        {
            if (i < 0 || j < 0 || i >= n || j >= m || g[i][j] != '1') continue;
            dfs(i, j);
        }
    }
}
double get_dist(pii& a, pii& b)
{
    double dx = a.x - b.x, dy = a.y - b.y;
    return sqrt(dx * dx + dy * dy);
}
double get_hash()
{
    double sum = 0;
    for (int i = 0; i < top; i++)
    {
        for (int j = i + 1; j < top; j++)
        {
            sum += get_dist(q[i], q[j]);
        }
    }
    return sum;
}
char get_id(double t)
{
    for (int i = 0; i < cnt; i++)
    {
        if (abs(hashs[i] - t) < eps) return 'a' + i;
    }
    hashs[cnt++] = t;
    return 'a' + cnt - 1;
}
int main()
{
    cin >> m >> n;
    for (int i = 0; i < n; i++) cin >> g[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (g[i][j] == '1')
            {
                top = 0;
                dfs(i, j);
                double h = get_hash();
                char c = get_id(h);
                for (int i = 0; i < top; i++)
                {
                    auto t = q[i];
                    g[t.x][t.y] = c;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) cout << g[i] << endl;
    return 0;
}